// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   RestoreFrame.java

package com.boci.clientapp.main;

import com.boci.common.ui.constant.UIConst;
import com.boci.common.util.*;
import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.*;
import java.awt.event.*;
import java.util.Locale;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.border.EtchedBorder;

// Referenced classes of package com.boci.clientapp.main:
//            ClientAppLoader, TradingClientApp

public class RestoreFrame extends JFrame
    implements ActionListener, MouseListener, MouseMotionListener
{

    private void initConfig()
    {
        setLocation(UIConst.APP_RESTORE_FRAME_X, UIConst.APP_RESTORE_FRAME_Y);
        setTitle(strWinTitle);
        setDefaultCloseOperation(0);
        addMouseListener(this);
        addMouseMotionListener(this);
        addWindowListener(new WindowAdapter() {

            public void windowClosing(WindowEvent e)
            {
                mainFrame.windowClosing(e);
            }
        }
);
    }

    public RestoreFrame(TradingClientApp pMainFrame, String pTitle)
    {
        origin = new Point();
        logger = CMLogger.getInstance();
        msgConf = ClientAppLoader.getMessagesConfigurator();
        mainFrame = pMainFrame;
        strWinTitle = pTitle;
        initConfig();
        initGUI();
    }

    private void initGUI()
    {
        try
        {
            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
        }
        catch(UnsupportedLookAndFeelException e)
        {
            logger.info(StringUtil.formatException(e));
        } catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (InstantiationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
        setIconImage(ClientAppLoader.getIconImage());
        setUndecorated(true);
        setSize(new Dimension(123, 34));
        buttonPanel = new JPanel();
        buttonPanel.setBackground(Color.WHITE);
        buttonPanel.setLayout(null);
        getContentPane().add(buttonPanel, "Center");
        restoreButton = new JButton();
        restoreButton.setFont(new Font("", 0, 10));
        restoreButton.setBounds(40, 7, 60, 20);
        restoreButton.setText("Restore");
        restoreButton.setMargin(new Insets(0, 0, 0, 0));
        buttonPanel.add(restoreButton);
        closeButton = new JButton();
        closeButton.setFont(new Font("Arial", 1, 12));
        closeButton.setBounds(100, 7, 20, 20);
        closeButton.setMargin(new Insets(0, 0, 3, 0));
        closeButton.setText("x");
        buttonPanel.add(closeButton);
        closeButton.addActionListener(this);
        restoreButton.addActionListener(this);
        lblIcon = new JLabel();
        lblIcon.setIcon(ClientAppLoader.getIcon());
        lblIcon.setBounds(4, 2, 120, 30);
        buttonPanel.add(lblIcon);
        borderPanel = new JPanel();
        borderPanel.setBorder(new EtchedBorder(1));
        borderPanel.setOpaque(false);
        borderPanel.setBounds(1, 1, 121, 32);
        buttonPanel.add(borderPanel);
    }

    public void setText(Locale pLocale)
    {
        restoreButton.setText(msgConf.getUIMessages("MINISCREEN.RESTORE", pLocale));
        setFont(pLocale);
    }

    public void setFont(Locale pLocale)
    {
        restoreButton.setFont(ClientAppLoader.getSmallPlainTextFont(pLocale));
    }

    public void actionPerformed(ActionEvent e)
    {
        if(e.getSource() == closeButton)
            mainFrame.windowClosing(new WindowEvent(this, 201));
        else
        if(e.getSource() == restoreButton)
        {
            setVisible(false);
            mainFrame.restore();
        }
    }

    public void mouseClicked(MouseEvent mouseevent)
    {
    }

    public void mouseEntered(MouseEvent mouseevent)
    {
    }

    public void mouseExited(MouseEvent mouseevent)
    {
    }

    public void mousePressed(MouseEvent e)
    {
        origin.x = e.getX();
        origin.y = e.getY();
    }

    public void mouseReleased(MouseEvent mouseevent)
    {
    }

    public void mouseDragged(MouseEvent e)
    {
        Point p = getLocation();
        setLocation((p.x + e.getX()) - origin.x, (p.y + e.getY()) - origin.y);
    }

    public void mouseMoved(MouseEvent mouseevent)
    {
    }

    public void setVisible(boolean pVisible, Locale pLocale)
    {
        if(pVisible)
            setText(pLocale);
        setVisible(pVisible);
    }

    private Point origin;
    private TradingClientApp mainFrame;
    private JButton closeButton;
    private JButton restoreButton;
    private JPanel buttonPanel;
    private JLabel lblIcon;
    private JPanel borderPanel;
    private String strWinTitle;
    private Logger logger;
    private MessagesConfigurator msgConf;

}
